package query

import (
	"strings"

	"ssdevice/common/dto"
)

type SysProductVariableQuery struct {
	dto.Pagination `search:"-"`
	dto.OrderBy    `search:"-"`
	dto.UserInfo
	ProductModel  string `form:"productModel"  search:"type:exact;column:product_model;table:sys_product_variable"`
	ProductModels string `form:"productModels" search:"-"`
	Keys          string `form:"keys" search:"-"`
	DeptId        string `form:"deptId" search:"-"`
	DeptIdNot     string `form:"deptIdNot" search:"-"`
	Type          string `form:"type"  search:"type:exact;column:type;table:sys_product_variable"`

	ProductModelIn []string `search:"type:in;column:product_model;table:sys_product_variable"`
	KeyIn          []string `search:"type:in;column:key;table:sys_product_variable"`
}

func (m *SysProductVariableQuery) GetNeedSearch() interface{} {
	if len(m.ProductModels) > 0 {
		m.ProductModelIn = strings.Split(strings.ReplaceAll(m.ProductModels, " ", ""), ",")
	}
	if len(m.Keys) > 0 {
		m.KeyIn = strings.Split(strings.ReplaceAll(m.Keys, " ", ""), ",")
	}
	return *m
}
